﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeBehind="ManuFacture.aspx.cs" Inherits="UdrinkWater_Project.Officer.ManuFacture" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
      <script type="text/javascript">
    // <![CDATA[
          function ShowSertEmpWindow() {
              pcDataEmp.Show();
          }
          function ShowSertCusWindow() {
              pcCusData.Show();
          }
          function ShowSertProWindow() {
              pcProduct.Show();
          }

          function ShowMat() {
              pct.Show();
          }
    // ]]> 
    </script>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <dx:ASPxPopupControl ID="pcProduct" runat="server" CloseAction="CloseButton" Modal="True"
        PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" ClientInstanceName="pcProduct"
        HeaderText="ค้นหาสินค้า" AllowDragging="True" PopupAnimationType="None" EnableViewState="False" Width="960px">
        <ClientSideEvents PopUp="function(s, e) { ASPxClientEdit.ClearGroup('entryGroup'); }" />
         <ContentCollection>
<dx:PopupControlContentControl ID="PopupControlContentControl1" runat="server" SupportsDisabledAttribute="True">
    <table style="width: 100%">
        <tr>
            <td>
                <asp:SqlDataSource ID="SqlProduct" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                    
                    SelectCommand="SELECT TB_Product.Product_ID, TB_Product.Product_name, TB_Unit_Category.Unit_Name, TB_Product.Price, TB_Product.In_Stock, TB_Product.Image_Path FROM TB_Product LEFT JOIN TB_Unit_Category ON TB_Product.Unit = TB_Unit_Category.Unit_ID">
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td align="center">
                <dx:ASPxGridView ID="ASPxGridView4" runat="server" AutoGenerateColumns="False" 
                    DataSourceID="SqlProduct" KeyFieldName="Product_ID" Width="80%" 
                    OnRowCommand="ASPxGridView4_RowCommand">
                    <Columns>
                        <dx:GridViewDataTextColumn Caption="เลือก" ShowInCustomizationForm="True" 
                            VisibleIndex="7">
                            <DataItemTemplate>
                                <table style="width: 100%">
                                    <tr>
                                        <td align="center">
                                            <dx:ASPxButton ID="btSertProd" runat="server" Text="เลือก" CommandName="Cmd_Select"  CommandArgument='<%# Eval("Product_ID") %>'>
                                                <ClientSideEvents Click="function(s, e) {
	pcProduct.Hide();
}" />
                                            </dx:ASPxButton>
                                        </td>
                                    </tr>
                                </table>
                            </DataItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" />
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewCommandColumn ShowInCustomizationForm="True" VisibleIndex="0" 
                            Visible="False">
                            <ClearFilterButton Visible="True">
                            </ClearFilterButton>
                        </dx:GridViewCommandColumn>
                        <dx:GridViewDataTextColumn FieldName="Product_ID" ReadOnly="True" 
                            ShowInCustomizationForm="True" VisibleIndex="2" Caption="รหัสสินค้า">
                            <Settings AutoFilterCondition="Contains" FilterMode="DisplayText" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn FieldName="Product_name" 
                            ShowInCustomizationForm="True" VisibleIndex="3" Caption="ชื่อสินค้า">
                            <Settings AutoFilterCondition="Contains" FilterMode="DisplayText" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn FieldName="Unit_Name" ShowInCustomizationForm="True" 
                            VisibleIndex="4" Caption="หน่วย">
                            <Settings AutoFilterCondition="Contains" FilterMode="DisplayText" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn FieldName="Price" ShowInCustomizationForm="True" 
                            VisibleIndex="5" Caption="ราคา/หน่วย">
                            <Settings AutoFilterCondition="Contains" FilterMode="DisplayText" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn FieldName="In_Stock" ShowInCustomizationForm="True" 
                            VisibleIndex="6" Caption="จำนวนคงเหลือ" Visible="False">
                            <Settings AutoFilterCondition="Contains" FilterMode="DisplayText" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataBinaryImageColumn FieldName="Image_Path" 
                            ShowInCustomizationForm="True" VisibleIndex="1" Caption="รูปภาพ" 
                            Visible="False">
                            <HeaderStyle HorizontalAlign="Center" />
                        </dx:GridViewDataBinaryImageColumn>
                    </Columns>
                    <Settings ShowFilterRow="True" />
                </dx:ASPxGridView>
            </td>
        </tr>
    </table>
             </dx:PopupControlContentControl>
</ContentCollection>
     </dx:ASPxPopupControl>
     <dx:ASPxPopupControl ID="pcDataEmp" runat="server" CloseAction="CloseButton" Modal="True"
        PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" ClientInstanceName="pcDataEmp"
        HeaderText="ค้นหาพนักงาน" AllowDragging="True" PopupAnimationType="None" 
         EnableViewState="False" Width="960px">
        <ClientSideEvents PopUp="function(s, e) { ASPxClientEdit.ClearGroup('entryGroup'); }" />
<ContentCollection>
<dx:PopupControlContentControl ID="PopupControlContentControl2" runat="server" SupportsDisabledAttribute="True">
    <table style="width: 100%">
        <tr>
            <td>
                <asp:SqlDataSource ID="SqlEmp" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                    SelectCommand="SELECT ID_Card,( Prefix + '' + Firstname + ' ' + Lastname ) AS Name FROM TB_Employee">
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td align="center">
                <dx:ASPxGridView ID="ASPxGridView2" runat="server" AutoGenerateColumns="False" 
                    DataSourceID="SqlEmp" KeyFieldName="ID_Card" Width="80%" 
                    OnRowCommand="ASPxGridView2_RowCommand">
                    <Columns>
                        <dx:GridViewCommandColumn ShowInCustomizationForm="True" Visible="False" 
                            VisibleIndex="0">
                            <ClearFilterButton Text="ยกเลิก" Visible="True">
                            </ClearFilterButton>
                        </dx:GridViewCommandColumn>
                        <dx:GridViewDataTextColumn 
                            ShowInCustomizationForm="True" VisibleIndex="3" Caption="เลือก">
                            <DataItemTemplate>
                                <table style="width: 100%">
                                    <tr>
                                        <td align="center">
                                            <dx:ASPxButton ID="btEmpChose" runat="server" Text="เลือก" CommandName="Cmd_Select"  CommandArgument='<%#Eval("ID_Card")%>'>
                                                <ClientSideEvents Click="function(s, e) {
	pcDataEmp.Hide();
}" />
                                            </dx:ASPxButton>
                                        </td>
                                    </tr>
                                </table>
                            </DataItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" />
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn FieldName="ID_Card" ReadOnly="True" 
                            ShowInCustomizationForm="True" VisibleIndex="1" 
                            Caption="ค้นหาจากรหัสพนักงาน" Width="250px">
                            <Settings AutoFilterCondition="Contains" FilterMode="DisplayText" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn FieldName="Name" ReadOnly="True" 
                            ShowInCustomizationForm="True" VisibleIndex="2" Caption="ค้นหาจากชื่อ" 
                            Width="250px">
                            <Settings AutoFilterCondition="Contains" FilterMode="DisplayText" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </dx:GridViewDataTextColumn>
                    </Columns>
                    <Settings ShowFilterRow="True" />
                </dx:ASPxGridView>
            </td>
        </tr>
    </table>
    </dx:PopupControlContentControl>
</ContentCollection>
     </dx:ASPxPopupControl>
       <dx:ASPxPopupControl ID="pct" runat="server" CloseAction="CloseButton" Modal="True"
        PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" ClientInstanceName="pct"
        HeaderText="ค้นหาวัตถุดิบ" AllowDragging="True" PopupAnimationType="None" 
          EnableViewState="False" Width="960px">
        <ClientSideEvents PopUp="function(s, e) { ASPxClientEdit.ClearGroup('entryGroup');  }" />
        <ContentCollection>
<dx:PopupControlContentControl runat="server" SupportsDisabledAttribute="True">
    <table style="width: 100%">
        <tr>
            <td align="center">
                <dx:ASPxGridView ID="ASPxGridView5" runat="server" AutoGenerateColumns="False" 
                    DataSourceID="SqlDataSource3" KeyFieldName="Material_ID" 
                    OnRowCommand="ASPxGridView5_RowCommand" Width="80%">
                    <Columns>
                        <dx:GridViewCommandColumn ShowInCustomizationForm="True" Visible="False" 
                            VisibleIndex="0">
                            <ClearFilterButton Text="ยกเลิก" Visible="True">
                            </ClearFilterButton>
                        </dx:GridViewCommandColumn>
                        <dx:GridViewDataTextColumn Caption="เลือก" ShowInCustomizationForm="True" 
                            VisibleIndex="4">
                            <DataItemTemplate>
                                <table style="width: 100%">
                                    <tr>
                                        <td align="center">
                                            <dx:ASPxButton ID="btEmpChose0" runat="server" 
                                                CommandArgument='<%#Eval("Material_ID")%>' CommandName="Cmd_Select" 
                                                Text="เลือก">
                                                <ClientSideEvents Click="function(s, e) {
	pct.Hide();
}" />
                                            </dx:ASPxButton>
                                        </td>
                                    </tr>
                                </table>
                            </DataItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" />
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn Caption="ค้นหาจากรหัสวัตถุดิบ" 
                            FieldName="Material_ID" ReadOnly="True" ShowInCustomizationForm="True" 
                            VisibleIndex="1" Width="250px">
                            <Settings AutoFilterCondition="Contains" FilterMode="DisplayText" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn Caption="ค้นหาจากชื่อวัตถุดิบ" 
                            FieldName="Materail_name" ReadOnly="True" ShowInCustomizationForm="True" 
                            VisibleIndex="2" Width="250px">
                            <Settings AutoFilterCondition="Contains" FilterMode="DisplayText" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataTextColumn Caption="หน่วย" FieldName="Unit_Name" 
                            ShowInCustomizationForm="True" VisibleIndex="3">
                            <Settings AutoFilterCondition="Contains" FilterMode="DisplayText" />
                        </dx:GridViewDataTextColumn>
                    </Columns>
                    <Settings ShowFilterRow="True" />
                </dx:ASPxGridView>
            </td>
        </tr>
    </table>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
        SelectCommand="SELECT TB_Material.Material_ID, TB_Material.Materail_name, TB_Unit_Category.Unit_Name FROM TB_Material LEFT OUTER JOIN TB_Unit_Category ON TB_Material.Unit = TB_Unit_Category.Unit_ID">
    </asp:SqlDataSource>
              </dx:PopupControlContentControl>
</ContentCollection>
      </dx:ASPxPopupControl>
      <dx:ASPxRoundPanel ID="ASPxRoundPanel1" runat="server" HeaderText="ผลิตสินค้า" 
        Width="1080px">
        <HeaderStyle Font-Size="Large" />
        <PanelCollection>
            <dx:PanelContent ID="PanelContent1" runat="server" SupportsDisabledAttribute="True">
                <table style="width: 100%">
                    <tr>
                        <td width="40%" valign="top" style="height: inherit">
                             <asp:Panel ID="Panel2" runat="server">
                                <fieldset><legend>วันที่เวลา</legend>
                                <asp:UpdatePanel ID="updDateOrder" runat="server">
                                    <ContentTemplate>
                                        <table style="width: 100%">
                                            <tr>
                                                <td style="width: 103px">
                                                    <dx:ASPxLabel ID="ASPxLabel3" runat="server" Text="วันเวลาเอกสาร:">
                                                    </dx:ASPxLabel>
                                                </td>
                                                <td>
                                                    <dx:ASPxTextBox ID="txtStockDate" runat="server" Width="225px" ReadOnly="True" 
                                                        BackColor="#D3E4A6">
                                                    </dx:ASPxTextBox>
                                                </td>
                                            </tr>
                                        </table>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </fieldset>
                                 <asp:Panel ID="Panel1" runat="server">
                                     <fieldset>
                                         <legend>พนักงาน</legend>
                                         <asp:UpdatePanel ID="udpEmp" runat="server">
                                             <ContentTemplate>
                                                 <table style="width: 100%">
                                                     <tr>
                                                         <td style="width: 78px">
                                                             <dx:ASPxLabel ID="ASPxLabel1" runat="server" Text="รหัสพนักงาน:">
                                                             </dx:ASPxLabel>
                                                         </td>
                                                         <td style="width: 244px">
                                                             <dx:ASPxTextBox ID="txtEmpID" runat="server" Width="225px" BackColor="#D3E4A6" 
                                                                 ReadOnly="True">
                                                             </dx:ASPxTextBox>
                                                         </td>
                                                         <td style="width: 11px" align="right" dir="ltr">
                                                             <dx:ASPxButton ID="btEmpSert" runat="server" Text="ค้นหา" Width="60px" 
                                                                 AutoPostBack="False" Height="23px">
                                                                 <ClientSideEvents Click="function(s, e) {
	 ShowSertEmpWindow();
}" />
                                                             </dx:ASPxButton>
                                                         </td>
                                                     </tr>
                                                     <tr>
                                                         <td style="width: 78px">
                                                             <dx:ASPxLabel ID="ASPxLabel2" runat="server" Text="ชื่อพนักงาน:">
                                                             </dx:ASPxLabel>
                                                         </td>
                                                         <td style="width: 244px">
                                                             <dx:ASPxTextBox ID="txtEmpName" runat="server" Width="225px" 
                                                                 BackColor="#D3E4A6" ReadOnly="True">
                                                             </dx:ASPxTextBox>
                                                         </td>
                                                         <td>
                                                             &nbsp;</td>
                                                     </tr>
                                                     <tr>
                                                         <td align="center" colspan="3">
                                                             <dx:ASPxLabel ID="lbWarnEmp" runat="server" ForeColor="Red" 
                                                                 Text="ไม่มีพนักงานในระบบ!" Visible="False">
                                                             </dx:ASPxLabel>
                                                         </td>
                                                     </tr>
                                                 </table>
                                             </ContentTemplate>
                                         </asp:UpdatePanel>
                                     </fieldset>
                                     <%--<fieldset>
                                     <legend>เพิ่มรายการวัตถุดิบ</legend>--%>
                                         <asp:UpdatePanel ID="UpdatePanel2" runat="server" Visible="False">
                                         <ContentTemplate>
                                     <table style="width: 100%">
                                         <tr>
                                             <td align="left" style="width: 86px">
                                                 <dx:ASPxLabel ID="ASPxLabel13" runat="server" Text="รหัสวัตถุดิบ:">
                                                 </dx:ASPxLabel>
                                             </td>
                                             <td align="left" style="width: 340px">
                                                 <dx:ASPxTextBox ID="txtMatID" runat="server" Width="225px" BackColor="#D0E1A3" 
                                                     ReadOnly="True">
                                                 </dx:ASPxTextBox>
                                             </td>
                                             <td align="left">
                                                 <dx:ASPxButton ID="btMat" runat="server" Text="ค้นหา" Width="60px" 
                                                     AutoPostBack="False">
                                                     <ClientSideEvents Click="function(s, e) {
	ShowMat();
}" />
                                                 </dx:ASPxButton>
                                             </td>
                                         </tr>
                                         <tr>
                                             <td align="left" style="width: 86px">
                                                 <dx:ASPxLabel ID="ASPxLabel14" runat="server" Text="ชื่อวัตถุดิบ">
                                                 </dx:ASPxLabel>
                                             </td>
                                             <td align="left" style="width: 340px">
                                                 <dx:ASPxTextBox ID="txtMatName" runat="server" Width="225px" 
                                                     BackColor="#D0E1A3" ReadOnly="True">
                                                 </dx:ASPxTextBox>
                                             </td>
                                             <td align="center">
                                                 &nbsp;</td>
                                         </tr>
                                         <tr>
                                             <td align="left" style="width: 86px">
                                                 <dx:ASPxLabel ID="ASPxLabel15" runat="server" Text="หน่วย:">
                                                 </dx:ASPxLabel>
                                             </td>
                                             <td align="left" style="width: 340px">
                                                 <dx:ASPxTextBox ID="txtMatU" runat="server" Width="225px" BackColor="#D0E1A3" 
                                                     ReadOnly="True">
                                                 </dx:ASPxTextBox>
                                             </td>
                                             <td align="center">
                                                 &nbsp;</td>
                                         </tr>
                                         <tr>
                                             <td align="left" style="width: 86px">
                                                 <dx:ASPxLabel ID="ASPxLabel17" runat="server" Text="จำนวนคงเหลือ:">
                                                 </dx:ASPxLabel>
                                             </td>
                                             <td align="left" style="width: 340px">
                                                 <dx:ASPxTextBox ID="txtMatStock" runat="server" BackColor="#D0E1A3" 
                                                     ReadOnly="True" Width="225px">
                                                 </dx:ASPxTextBox>
                                             </td>
                                             <td align="center">
                                                 &nbsp;</td>
                                         </tr>
                                         <tr>
                                             <td align="left" style="width: 86px">
                                                 <dx:ASPxLabel ID="ASPxLabel16" runat="server" Text="จำนวน">
                                                 </dx:ASPxLabel>
                                             </td>
                                             <td align="left" style="width: 340px">
                                                 <dx:ASPxTextBox ID="txtMatCount" runat="server" Width="225px">
                                                 </dx:ASPxTextBox>
                                             </td>
                                             <td align="center">
                                                 &nbsp;</td>
                                         </tr></table>
                                         </ContentTemplate>
                                     </asp:UpdatePanel>
                                     
                                     <table>
                                         <tr>
                                             <td align="center" style="width: 86px">
                                                 &nbsp;</td>
                                             <td align="center" style="width: 340px">
                                                 <dx:ASPxButton ID="ASPxButton1" runat="server" OnClick="ASPxButton1_Click" 
                                                     Text="เพิ่มรายการ" Visible="False">
                                                 </dx:ASPxButton>
                                             </td>
                                             <td align="center" style="width: 77px">
                                                 &nbsp;</td>
                                         </tr>
                                         </table>
                                    <%-- </fieldset>--%>
                                     </asp:Panel>
                            </asp:Panel>
                        </td>
                        <td width="40%" valign="top" style="height: inherit">
                            <asp:Panel ID="Panel4" runat="server" Height="100%">
                                <fieldset>
                                    <legend>เพิ่มสินค้าในรายการผลิต</legend>
                                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                        <ContentTemplate>
                                            <table style="width: 100%">
                                                <tr>
                                                    <td style="width: 127px">
                                                        <dx:ASPxLabel ID="ASPxLabel7" runat="server" Text="รหัสสินค้า:">
                                                        </dx:ASPxLabel>
                                                    </td>
                                                    <td style="width: 360px">
                                                        <dx:ASPxTextBox ID="txtProductId" runat="server" Width="225px" ReadOnly="True" 
                                                            BackColor="#D3E4A6">
                                                        </dx:ASPxTextBox>
                                                    </td>
                                                    <td>
                                                        <dx:ASPxButton ID="btProductSert" runat="server" Text="ค้นหา" Width="60px" 
                                                            AutoPostBack="False">
                                                            <ClientSideEvents Click="function(s, e) {
	ShowSertProWindow();
}" />
                                                        </dx:ASPxButton>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 127px">
                                                        <dx:ASPxLabel ID="ASPxLabel8" runat="server" Text="ชื่อสินค้า:">
                                                        </dx:ASPxLabel>
                                                    </td>
                                                    <td style="width: 360px">
                                                        <dx:ASPxTextBox ID="txtProductName" runat="server" Width="225px" 
                                                            ReadOnly="True" BackColor="#D3E4A6">
                                                        </dx:ASPxTextBox>
                                                    </td>
                                                    <td>
                                                        &nbsp;</td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 127px">
                                                        <dx:ASPxLabel ID="ASPxLabel10" runat="server" Text="จำนวนคงเหลือ:">
                                                        </dx:ASPxLabel>
                                                    </td>
                                                    <td style="width: 360px">
                                                        <dx:ASPxTextBox ID="txtInStock" runat="server" Width="180px" ReadOnly="True" 
                                                            BackColor="#D3E4A6">
                                                        </dx:ASPxTextBox>
                                                    </td>
                                                    <td rowspan="3">
                                                        &nbsp;</td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 127px">
                                                        <dx:ASPxLabel ID="ASPxLabel12" runat="server" Text="หน่วยสินค้า:">
                                                        </dx:ASPxLabel>
                                                    </td>
                                                    <td style="width: 360px">
                                                        <dx:ASPxTextBox ID="txtUnit" runat="server" Width="180px" ReadOnly="True" 
                                                            BackColor="#D3E4A6">
                                                        </dx:ASPxTextBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="height: 23px; width: 127px;">
                                                        <dx:ASPxLabel ID="ASPxLabel11" runat="server" Text="จำนวน:">
                                                        </dx:ASPxLabel>
                                                    </td>
                                                    <td style="height: 23px; width: 360px;">
                                                        <dx:ASPxTextBox ID="txtCount" runat="server" ClientInstanceName="txtCount" 
                                                            style="margin-bottom: 0px" Width="180px">
                                                        </dx:ASPxTextBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 127px">
                                                        &nbsp;</td>
                                                    <td style="width: 360px">
                                                        &nbsp;</td>
                                                    <td>
                                                        &nbsp;</td>
                                                </tr>
                                                <tr>
                                                    <td align="center" colspan="3">
                                                        <dx:ASPxLabel ID="lbWranList" runat="server" ForeColor="Red" 
                                                            Text="สินค้ามีในรายการแล้ว!" Visible="False">
                                                        </dx:ASPxLabel>
                                                    </td>
                                                </tr> 
                                                </table>
                                                </ContentTemplate>
                                    </asp:UpdatePanel>
                                   <table width="100%">
                                                <tr>
                                                    <td align="center" colspan="3" width="100%">
                                                        <dx:ASPxButton ID="btAddList" runat="server" OnClick="btAddList_Click" 
                                                            Text="เพิ่มรายการ">
                                                        </dx:ASPxButton>
                                                    </td>
                                                </tr>
                                     
                                        </table>   
                                           
                                        
                                </fieldset>
                                <table style="width: 100%">
                                    <tr>
                                        <td align="center" style="height: 27px" colspan="2">
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td align="center" style="height: 27px">
                                            <dx:ASPxButton ID="btSaveAndReport" runat="server" Height="50px" 
                                                OnClick="btSaveAndReport_Click" Text="บันทึกและพิมพ์รายการ" Width="180px">
                                            </dx:ASPxButton>
                                        </td>
                                        <td align="center" style="height: 27px">
                                            <dx:ASPxButton ID="btNewOrder" runat="server" Height="50px" 
                                                OnClick="btNewOrder_Click" Text="เริ่มรายการใหม่" Width="180px">
                                            </dx:ASPxButton>
                                        </td>
                                    </tr>
                                </table> 
                                
                            </asp:Panel>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:SqlDataSource ID="SqlDataSource1" runat="server"></asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:Panel ID="Panel6" runat="server">
                                <fieldset>
                                    <legend>รายการผลิต</legend>
                                    <dx:ASPxGridView ID="GV_OrderList" runat="server" AutoGenerateColumns="False" 
                                        Font-Size="Medium" KeyFieldName="Number" 
                                        OnFocusedRowChanged="GV_OrderList_FocusedRowChanged" 
                                        OnRowCommand="GV_OrderList_RowCommand" 
                                        OnSummaryDisplayText="GV_OrderList_SummaryDisplayText" Width="100%">
                                        <TotalSummary>
                                            <dx:ASPxSummaryItem DisplayFormat="รวม {0:#,###.00}" FieldName="TotalRow" 
                                                SummaryType="Sum" />
                                        </TotalSummary>
                                        <Columns>
                                            <dx:GridViewDataTextColumn Caption="รหัสสินค้า" FieldName="Product_ID" 
                                                ShowInCustomizationForm="True" VisibleIndex="1">
                                                <HeaderStyle HorizontalAlign="Center" />
                                                <CellStyle HorizontalAlign="Center">
                                                </CellStyle>
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn Caption="ชื่อสินค้า" FieldName="Product_Name" 
                                                ShowInCustomizationForm="True" VisibleIndex="2">
                                                <HeaderStyle HorizontalAlign="Center" />
                                                <CellStyle HorizontalAlign="Center">
                                                </CellStyle>
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn Caption="หน่วย" FieldName="Unit" 
                                                ShowInCustomizationForm="True" VisibleIndex="3">
                                                <HeaderStyle HorizontalAlign="Center" />
                                                <CellStyle HorizontalAlign="Center">
                                                </CellStyle>
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn Caption="จำนวน" FieldName="Count" 
                                                ShowInCustomizationForm="True" VisibleIndex="5">
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn Caption="รายการ" FieldName="Number" 
                                                ShowInCustomizationForm="True" UnboundType="String" VisibleIndex="0">
                                                <DataItemTemplate>
                                                    <%#Container.ItemIndex +1 %>
                                                </DataItemTemplate>
                                                <HeaderStyle HorizontalAlign="Center" />
                                                <CellStyle HorizontalAlign="Center">
                                                </CellStyle>
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn Caption="ลบ" ShowInCustomizationForm="True" 
                                                VisibleIndex="8">
                                                <DataItemTemplate>
                                                    <dx:ASPxButton ID="btnImageAndText" runat="server" BackColor="White" 
                                                        CommandArgument="<%# Container.ItemIndex %>" CommandName="Cmd_Delete" 
                                                        Text="ลบรายการ" Width="120px">
                                                        <Image Height="16px" Url="../images/Remove.png" Width="16px">
                                                        </Image>
                                                        <ClientSideEvents Click="function(s,e) { e.processOnServer = confirm('Are you sure?'); }" />
                                                    </dx:ASPxButton>
                                                </DataItemTemplate>
                                                <HeaderStyle HorizontalAlign="Center" />
                                                <CellStyle HorizontalAlign="Center">
                                                </CellStyle>
                                            </dx:GridViewDataTextColumn>
                                        </Columns>
                                        <SettingsBehavior ConfirmDelete="True" />
                                        <Settings ShowFooter="True" ShowGroupFooter="VisibleIfExpanded" />
                                        <SettingsText ConfirmDelete="ยืนยันการลบข้อมูล" />
                                    </dx:ASPxGridView>
                                </fieldset>
                                
                                    <dx:ASPxGridView ID="GV_OrderList0" runat="server" AutoGenerateColumns="False" 
                                        Font-Size="Medium" KeyFieldName="Number" 
                                        OnRowCommand="GV_OrderList0_RowCommand" Width="100%" Visible="False">
                                        <TotalSummary>
                                            <dx:ASPxSummaryItem DisplayFormat="รวม {0:#,###.00}" FieldName="TotalRow" 
                                                SummaryType="Sum" />
                                        </TotalSummary>
                                        <Columns>
                                            <dx:GridViewDataTextColumn Caption="รหัสวัตถุดิบ" FieldName="MatID" 
                                                ShowInCustomizationForm="True" VisibleIndex="1">
                                                <HeaderStyle HorizontalAlign="Center" />
                                                <CellStyle HorizontalAlign="Center">
                                                </CellStyle>
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn Caption="ชื่อวัตถุดิบ" FieldName="Mat_Name" 
                                                ShowInCustomizationForm="True" VisibleIndex="2">
                                                <HeaderStyle HorizontalAlign="Center" />
                                                <CellStyle HorizontalAlign="Center">
                                                </CellStyle>
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn Caption="หน่วย" FieldName="Unit" 
                                                ShowInCustomizationForm="True" VisibleIndex="3">
                                                <HeaderStyle HorizontalAlign="Center" />
                                                <CellStyle HorizontalAlign="Center">
                                                </CellStyle>
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn Caption="จำนวน" FieldName="Count" 
                                                ShowInCustomizationForm="True" VisibleIndex="5">
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn Caption="รายการ" FieldName="Number" 
                                                ShowInCustomizationForm="True" UnboundType="String" VisibleIndex="0">
                                                <DataItemTemplate>
                                                    <%#Container.ItemIndex +1 %>
                                                </DataItemTemplate>
                                                <HeaderStyle HorizontalAlign="Center" />
                                                <CellStyle HorizontalAlign="Center">
                                                </CellStyle>
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn Caption="ลบ" ShowInCustomizationForm="True" 
                                                VisibleIndex="8">
                                                <DataItemTemplate>
                                                    <dx:ASPxButton ID="btnImageAndText0" runat="server" BackColor="White" 
                                                        CommandArgument="<%# Container.ItemIndex %>" CommandName="Cmd_Delete" 
                                                        Text="ลบรายการ" Width="120px">
                                                        <Image Height="16px" Url="../images/Remove.png" Width="16px">
                                                        </Image>
                                                        <ClientSideEvents Click="function(s,e) { e.processOnServer = confirm('Are you sure?'); }" />
                                                    </dx:ASPxButton>
                                                </DataItemTemplate>
                                                <HeaderStyle HorizontalAlign="Center" />
                                                <CellStyle HorizontalAlign="Center">
                                                </CellStyle>
                                            </dx:GridViewDataTextColumn>
                                        </Columns>
                                        <SettingsBehavior ConfirmDelete="True" />
                                        <Settings ShowFooter="True" ShowGroupFooter="VisibleIfExpanded" />
                                        <SettingsText ConfirmDelete="ยืนยันการลบข้อมูล" />
                                    </dx:ASPxGridView>
                              
                            </asp:Panel>
                        </td>
                    </tr>
                </table>
            </dx:PanelContent>
        </PanelCollection>
    </dx:ASPxRoundPanel>
</asp:Content>
